package com.boolib.shopadmin.config.web;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;


import java.util.HashSet;
import java.util.Set;

@Configuration
public class WebConfig {


    @Bean
    public WebServerFactoryCustomizer webServerFactoryCustomizer(){

        return new WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>() {
            @Override
            public void customize(ConfigurableServletWebServerFactory factory) {
                Set<ErrorPage> errorPages =  new HashSet<>();
                errorPages.add(new ErrorPage(HttpStatus.NOT_FOUND,"/error/404"));
//                errorPages.add(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/error/500"));
                factory.setErrorPages(errorPages);
            }

        };
    }









}
